///************************************************************
/// @Copyright (C), 1993-2011, Chengdu Sifang Information Technologies Co., Ltd.
/// @URL:			http://www.cdsf.com
/// @FileName:		mallocc.c
/// @Author:		liuyuncheng	
/// @Version:		0.1
/// @Date:			Sat 26 Nov 2011 10:35:34 AM CST
/// @Description:	二维动态数组	
/// @History:		
///************************************************************
#include	<stdio.h>
#include	<stdlib.h>
#include 	<malloc.h>
#include	<string.h>

int main(int argc, char** argv)
{
	char **pp;
	int m = 5;
	int n =1;
	int i = 0;
	int j = 0;
	printf("sizeof(char) = %d\n",sizeof(char));
	printf("sizeof(char*) = %d\n",sizeof(char*));
	pp = (char**)malloc(sizeof(char*) * m);
	for(i = 0;i < m; i++)
	{
		*(pp + i) = (char*)malloc(sizeof(char)*n);
		memset(*(pp + i), 0 ,sizeof(char)*n);
	}
//start =========================================
		
	for(i = 0; i < m; i++)
	{
		memcpy(*(pp + i), "hellow", 6);
	}
	
	
	for(i = 0; i < m; i++)
	{
		printf("0x%x   ",(unsigned int)pp);//指针数组首地址
		printf("0x%x   ",(unsigned int)(pp + i));

		printf("0x%x   ",(unsigned int)*(pp+i));//指向具体类容
		printf("0x%x   ",(unsigned int)pp[i]);//同上
		printf("%s   ",(char*)pp[i]);
		printf("%d\n",strlen((char*)*(pp + i)));
	}
	
	
	//scanf("%d",&i);
//end ===========================================
	for(i = 0;i < m; i++)
	{
		free(*(pp + i));
	}
	free(pp);
	return 0;
}
